package com.keymozy.util;

import com.alibaba.fastjson.JSON;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class BaseUtil {
    /**
     * Base64编码
     * @param data
     * @return
     */
    public static String encoder(String data){
        Base64.Encoder encoder = Base64.getEncoder();
        byte[] encode = encoder.encode(data.getBytes(StandardCharsets.UTF_8));
        return new String(encode,StandardCharsets.UTF_8);
    }

    /**
     * 解码
     * @param data
     * @return
     */
    public static String decoder(String data){
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] decode = decoder.decode(data);
        return new String(decode,StandardCharsets.UTF_8);
    }
}
